package com.butterfly.hotkey.common.exception;

import org.springframework.util.CollectionUtils;

import java.util.Collection;

/**
 * @author butterfly
 * @version 1.0
 */
public class Asserts {

    public static void notNull(Object object, IException exceptionCode) {
        if (object == null) {
            throw new CommonException(exceptionCode);
        }
    }

    public static void notEmpty(Collection<?> collection, IException exceptionCode) {
        if (CollectionUtils.isEmpty(collection)) {
            throw new CommonException(exceptionCode);
        }
    }

    public static void isTrue(boolean expression, IException exceptionCode) {
        if (!expression) {
            throw new CommonException(exceptionCode);
        }
    }
}
